unit Studio;

interface

const

  STUDIO_VERSION		      = 44;

type

  TVector = record

  end;

  TQuaternion = record

  end;

  TRadianEuler = record

  end;

  TMatrix3x4 = record

  end;



  TStudioBone = record
    NameIndex: LongInt;

    Parent: LongInt;
    BoneController: array[0..5] of LongInt;

    Pos: TVector;
    Quat: TQuaternion;
    Rot: TRadianEuler;

    PosScale,
    RotScale: TVector;

    PoseToBone: TMatrix3x4;
    Alignment: TQuaternion;
    Flags,
    ProcType,
    ProcIndex,
    PhysicsBone,

    SurfacePropIndex,

    Contents: LongInt;

    Unused: array[0..7] of LongInt;
  public
    function Name: PChar;
    function Proc: Pointer;
    function SurfaceProp: PChar;
  end;

  TStudioBoneController = record
	  Bone,
	  AType: LongInt;
	  Start,
	  AEnd: Single;
	  Rest,
	  InputField: LongInt;
	  Unused: array[0..7] of LongInt;
  end;

  PStudioBBox = ^TStudioBBox;
  TStudioBBox = record
  	Bone,
	  Group: LongInt;
	  BBMin,
    BBMax: TVector;
	  HitBoxNameIndex: LongInt;
	  Unused: array[0..7] of LongInt;
  public
    function HitBoxName: PChar;
  end;

  TStudioHitBoxSet = record
	  NameIndex,
    NumHitBoxes,
	  HitBoxIndex: LongInt;
  public
    function Name: PChar;
    function HitBox(Index: Integer): PStudioBBox;
  end;

  PStudioMovement = ^TStudioMovement;
  TStudioMovement = record
	  FndFrame,
    MotionFlags: LongInt;
	  V0,
	  V1,
	  Angle: Single;
	  Vector,
	  Position: TVector;
  end;

  TStudioAnimDesc = record
    BasePtr,

    NameIndex: LongInt;

    FPS: Single;
    Flags,

    NumFrames,

    NumMovements,
    MovementIndex: LongInt;

    Unused1,
    Unused2: TVector;

    Animblock,
    Animindex,

    NumIKRules,
    IKRuleIndex,
    AnimBlockIKRuleIndex: LongInt;

    Unused: array[0..6] of LongInt;
  public
    function Name: PChar;
    function Movement(Index: Integer): PStudioMovement;
//inline studiohdr_t	*pStudiohdr( void ) const { return (studiohdr_t *)(((byte *)this) + baseptr); }
//mstudioanim_t *pAnim( void ) const;
//mstudioikrule_t *pIKRule( int i ) const;

  end;


implementation


{ TStudioBone }

function TStudioBone.Name: PChar;
begin
  Result := PChar(Integer(@Self) + NameIndex);
end;

function TStudioBone.Proc: Pointer;
begin
  if ProcIndex = 0 then
    Result := nil
  else
    Result := Pointer(Integer(@Self) + ProcIndex);
end;

function TStudioBone.SurfaceProp: PChar;
begin
  Result := PChar(Integer(@Self) + SurfacePropIndex);
end;

{ TStudioBBox }

function TStudioBBox.HitBoxName: PChar;
begin
  if HitBoxNameIndex = 0 then
    Result := ''
  else
    Result := PChar(Integer(@Self) + HitBoxNameIndex);
end;

{ TStudioHitBoxSet }

function TStudioHitBoxSet.HitBox(Index: Integer): PStudioBBox;
begin
  Result := PStudioBBox(Integer(@Self) + HitBoxIndex + Index * SizeOf(TStudioBBox));
end;

function TStudioHitBoxSet.Name: PChar;
begin
  Result := PChar(Integer(@Self) + NameIndex);
end;

{ TStudioAnimDesc }

function TStudioAnimDesc.Movement(Index: Integer): PStudioMovement;
begin
  Result := PStudioMovement(Integer(@Self) + MovementIndex + Index * SizeOf(TStudioMovement));
end;

function TStudioAnimDesc.Name: PChar;
begin
  Result := PChar(Integer(@Self) + NameIndex);
end;

end.
